package io.renren.modules.ProjectControl;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.renren.common.utils.R;
import io.renren.modules.ProjectControl.Service.taskService.TaskServiceP3;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/business")
public class BusinessController {
    @Autowired
    private TaskServiceP3 taskServiceP3;
    @RequestMapping("/Project3/datamodel/list")
    public R list(@RequestParam Map<String, Object> params, @RequestHeader("token") String token){

        return taskServiceP3.getList(params,token);
    }

    @RequestMapping("/Project3/dicmodelprop/list")
    private R dicpropList(@RequestParam Map<String, Object> params, @RequestHeader("token") String token){

       return taskServiceP3.getPropList(params,token);

    }


    @RequestMapping("/Project3/dataapstask/list")
    private R dataApsTaskList(@RequestParam Map<String, Object> params, @RequestHeader("token") String token){
        return taskServiceP3.getDataapsTaskList(params,token);
    }
    @RequestMapping("/Project3/dataapstask/findAllModules")
    private String dataApsTaskfindAllModules(@RequestParam Map<String, Object> params, @RequestHeader("token") String token){
        return taskServiceP3.getDataApsTaskAllMoudles(token);
    }
    @RequestMapping("/Project3/datamodel/allDataInfo")
    private R allDataInfo(@RequestHeader("token") String token){
        return taskServiceP3.getAllDataInfo(token);
    }


    @RequestMapping("/Project3/getModule/{id}")
    private String getModuleById(@PathVariable("id") String id, @RequestHeader("token") String token){
        return taskServiceP3.getModuleById(id,token);

    }
    @PostMapping("/Project3/saveModule")
    private Boolean saveModule(@RequestHeader("token") String token,@RequestParam(value = "Aps")String params){

        System.out.println(params);
        return taskServiceP3.saveMoule(params,token);
//        return true;

    }


    @PostMapping("/Project3/getOriginalSchedule/{Id}")
    private  R getOriginalSchedule(@RequestParam("file")MultipartFile file, @PathVariable String Id, @RequestParam("token") String token) throws IOException {
//        String token=httpRequest.getHeader("token");

        return taskServiceP3.getOriginalSchedule(file,Id,token);

    }

    @RequestMapping("/Project3/dataapstask/delete")
    private R deleteApsTask(@RequestBody Integer[] ids,@RequestHeader("token")String token) throws JsonProcessingException {



        return taskServiceP3.deleteApsTask(ids,token);
    }























}
